package cn.gcyl.module.biz.dal.mysql.marketinformation;

import cn.gcyl.framework.common.pojo.PageResult;
import cn.gcyl.framework.mybatis.core.mapper.BaseMapperX;
import cn.gcyl.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.gcyl.module.biz.controller.admin.marketinformation.vo.*;
import cn.gcyl.module.biz.dal.dataobject.marketinformation.MarketInformationDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 市场资讯 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface MarketInformationMapper extends BaseMapperX<MarketInformationDO> {

    default PageResult<MarketInformationDO> selectPage(MarketInformationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MarketInformationDO>()
                .likeIfPresent(MarketInformationDO::getInformationName, reqVO.getInformationName())
                .eqIfPresent(MarketInformationDO::getSort, reqVO.getSort())
                .eqIfPresent(MarketInformationDO::getStatus, reqVO.getStatus())
                .eqIfPresent(MarketInformationDO::getRecommendedStatus, reqVO.getRecommendedStatus())
                .eqIfPresent(MarketInformationDO::getImagePath, reqVO.getImagePath())
                .eqIfPresent(MarketInformationDO::getDetails, reqVO.getDetails())
                .betweenIfPresent(MarketInformationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MarketInformationDO::getId));
    }

    default PageResult<MarketInformationDO> getAppMarketInformationPage(MarketInformationPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<MarketInformationDO>()
                .likeIfPresent(MarketInformationDO::getInformationName, reqVO.getInformationName())
                .eqIfPresent(MarketInformationDO::getSort, reqVO.getSort())
                .eqIfPresent(MarketInformationDO::getStatus, reqVO.getStatus())
                .eqIfPresent(MarketInformationDO::getRecommendedStatus, reqVO.getRecommendedStatus())
                .eqIfPresent(MarketInformationDO::getImagePath, reqVO.getImagePath())
                .eqIfPresent(MarketInformationDO::getDetails, reqVO.getDetails())
                .betweenIfPresent(MarketInformationDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(MarketInformationDO::getId));
    }

}